package com.arpa.ntocc.common.common.util;

import cn.hutool.core.collection.IterUtil;
import com.arpa.ntocc.common.common.exception.ServiceException;
import com.google.common.collect.Maps;

import java.util.List;
import java.util.Map;

public class ShipmentWarehouseValidate {

    /**
     * 校验授权仓库code和货主code不能为空
     */
    /*public static void validateShipmentCodesAndWarehouseCodes() {
        List<String> warehouseCodes = UserUtil.getAuthorizeWarehouseCodes();
        List<String> shipmentCodes = UserUtil.getAuthorizeShipmentCodes();

        if (IterUtil.isEmpty(warehouseCodes) || IterUtil.isEmpty(shipmentCodes)) {
            throw new ServiceException("请先对仓库和货主授权，然后重新登录！！！");
        }
    }*/

    /**
     * 校验授权仓库code和货主code不能为空
     */
    public static Map<String,List<String>> validateShipmentCodesAndWarehouseCodes() {
        Map<String, List<String>> authMap = Maps.newHashMap();
        List<String> warehouseCodes = UserUtil.getAuthorizeWarehouseCodes();
        List<String> shipmentCodes = UserUtil.getAuthorizeShipmentCodes();

        if (IterUtil.isEmpty(warehouseCodes) || IterUtil.isEmpty(shipmentCodes)) {
            throw new ServiceException("请先对仓库和货主授权，然后重新登录！！！");
        }

        authMap.put("warehouseCodes", warehouseCodes);
        authMap.put("shipmentCodes", shipmentCodes);
        return authMap;
    }

}
